package cn.tedu.msfrsp.config;

import lombok.extern.slf4j.Slf4j;
import org.hibernate.validator.HibernateValidator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.validation.Validation;
import javax.validation.Validator;

/**
 * @author : zlh
 * @date : 2022-11-01 14:13
 **/
@Slf4j
@Configuration
public class ValidationConfiguration {
    public ValidationConfiguration() {
        log.debug("创建配置类对象:ValidationConfiguration");
    }

    @Bean
    public Validator validator(){
        return Validation.byProvider(HibernateValidator.class)
                .configure()//开始配置
                .failFast(true)//快速失败，即检查请求参数时，一旦发现某个参数不符合规则，则视为失败，并停止检查
                .buildValidatorFactory()
                .getValidator();
    }
}
